/**
 * 
 */
package edu.cmich.cps.cps240.partyprincesspalace.hw06;

import static org.junit.Assert.*;

import java.awt.Point;
import java.awt.Rectangle;
import java.util.Vector;

import org.junit.Test;

/**
 * @author roric1je
 *
 */
public class WirePinTest {

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#getParent()}.
	 */
	@Test
	public void testGetParent() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals(wire, wpin.getParent());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#setParent(edu.cmich.cps.cps240.partyprincesspalace.hw06.WorkspaceObj)}.
	 */
	@Test
	public void testSetParent() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals(wire, wpin.getParent());
		wpin.setParent(null);
		assertNotNull(wpin.getParent());
		wpin.setParent(wire);
		assertEquals(wire, wpin.getParent());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#getPartner()}.
	 */
	@Test
	public void testGetPartner() {
		Wire wire = new Wire();
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Rectangle rec = new Rectangle();
		Chip chip = new Chip(rec, ins, outs, "chip");
		ChipPin cpin = new ChipPin("cpin", chip, null);
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals(null, wpin.getPartner());
		wpin.setPartner(cpin);
		assertEquals(cpin, wpin.getPartner());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#setPartner(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testSetPartner() {
		Wire wire = new Wire();
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Rectangle rec = new Rectangle();
		Chip chip = new Chip(rec, ins, outs, "chip");
		ChipPin cpin = new ChipPin("cpin", chip, null);
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals(null, wpin.getPartner());
		wpin.setPartner(cpin);
		assertEquals(cpin, wpin.getPartner());
		wpin.setPartner(null);
		assertEquals(null, wpin.getPartner());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#getName()}.
	 */
	@Test
	public void testGetName() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals("name", wpin.getName());
		wpin.setName("");
		assertEquals("", wpin.getName());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#setName(java.lang.String)}.
	 */
	@Test
	public void testSetName() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertEquals("name", wpin.getName());
		wpin.setName("");
		assertEquals("", wpin.getName());
		wpin.setName(null);
		assertNotNull(wpin.getName());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#isInput()}.
	 */
	@Test
	public void testIsInput() {
		//Can't test this
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#isOutput()}.
	 */
	@Test
	public void testIsOutput() {
		//Can't test this
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#WirePin(java.lang.String, edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire, edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin)}.
	 */
	@Test
	public void testWirePinStringWireChipPin() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertNotNull(wpin);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#WirePin(edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin)}.
	 */
	@Test
	public void testWirePinWirePin() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		assertNotNull(wpin);
		WirePin wpinCopy = new WirePin(wpin);
		assertNotNull(wpinCopy);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#getLocation()}.
	 */
	@Test
	public void testGetLocation() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		Point spot = new Point(5, 5);
		wpin.setLocation(spot);
		assertEquals(spot, wpin.getLocation());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#setLocation(java.awt.Point)}.
	 */
	@Test
	public void testSetLocation() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		Point spot = new Point(5, 5);
		wpin.setLocation(spot);
		assertEquals(spot, wpin.getLocation());
		Point badSpot = new Point(-1, 5);
		wpin.setLocation(badSpot);
		assertEquals(spot, wpin.getLocation());
		badSpot.setLocation(5, -10);
		wpin.setLocation(badSpot);
		assertEquals(spot, wpin.getLocation());
		badSpot.setLocation(-10, -10);
		wpin.setLocation(badSpot);
		assertEquals(spot, wpin.getLocation());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin#closeToPin(java.awt.Point)}.
	 */
	@Test
	public void testCloseToPin() {
		Point spot = new Point(5, 5);
		Wire wire = new Wire();
		WirePin wpin = new WirePin("name", wire, null);
		wpin.setLocation(spot);
		assertTrue(wpin.closeToPin(wpin.getLocation()));
	}

}
